<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <title>show Page</title>
    <meta charset="UTF-8">
    <script src="{{ url_for('static', filename='js/jquery-3.3.1.js') }}"></script>
    <script src="{{ url_for('static', filename='js/function_all.js') }}"></script>
</head>

{% block content %} 

<style>
    .tableShow{
 white-space: nowrap;
}
</style>
<body>
<!--展示结构-->

<div id="head">
</div>
<div id="container">
</div>


<script type="text/javascript">
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return decodeURI(r[2]); return null; //返回参数值
    }
    $.ajax({
        url: "/getMatchData",
        type: "GET",
        data: {
            bt: getUrlParam("bt")
        }
    }).done(function (data) {
        var text_usr_dict = JSON.parse(data);
          //将数据显示出来--动态生成表格--相似患者
        // var text_usr_dict = jsjx();//获取相似患者数据
        var table="<table border=1><th rowspan=\"1\">序号</th>";
            table+=" <th rowspan=\"1\" width=100>相似[性别][年龄][体重][身高]</th>";
            table+=" <th rowspan=\"1\" width=100>原始[性别][年龄][体重][身高]</th>";
            table+="<th rowspan=\"1\"><li ><a href=' + 'show1?st=' + 1 + '>信息相似度</a></li></th>";
            table+="<th rowspan=\"1\" width=300>相似自述</th>";
            table+="<th rowspan=\"1\" width=300>原始自述</th>";
            table+="<th rowspan=\"1\"><li ><a href=' + 'show1?st=' + 2 + '>自述相似度</a></li></th>";
            table+="<th rowspan=\"1\" width=300 >相似问诊单选项</th>";
            table+="<th rowspan=\"1\" width=300 >原始问诊单选项</th>";
            table+="<th rowspan=\"1\"><li ><a href=' + 'show1?st=' + 3+ '>问诊单相似度</a></li></th>";
            table+="<th rowspan=\"1\" width=100>相似舌照特征</th>";
            table+="<th rowspan=\"1\" width=100>原始舌照特征</th>";
            table+="<th rowspan=\"1\"><li ><a href=' + 'show1?st=' + 4+ '>舌照相似度</a></li></th>";
            table+="<th rowspan=\"1\" >相似舌照</th>";
            table+="<th rowspan=\"1\" >原始舌照</th>";
            table+="<th rowspan=\"1\" width=200>相似辨证或辨病</th>";
            table+="<th rowspan=\"1\" width=200>原始辨证或辨病</th>";
            table+="<th rowspan=\"1\" width=200>相似药方</th>";
            table+="<th rowspan=\"1\" width=200>原始药方</th>";
            table+="<th rowspan=\"1\"><li ><a href=' + 'show1?st=' + 5+ '>总得分相似度</a></li></th>";



        //循环生成表格的每一行
        var length = text_usr_dict.length -1;
        var user_info = text_usr_dict[length]['user_info'];
        var report_orig = text_usr_dict[length]['report'];
        var inquiry_sheet = text_usr_dict[length]['inquiry_sheet'];
        var tongue_picture = text_usr_dict[length]['tongue_picture'];
        var tongue_feature = text_usr_dict[length]['tongue_feature'];
        var tongue_description = text_usr_dict[length]['tongue_description'];
        var diagnosis_orig = text_usr_dict[length]['diagnosis'];
        var herbs = text_usr_dict[length]['herbs'];
        // var sort = 0;


        for(var i=0;i<text_usr_dict.length-1;i++){

            //将原始患者自述与相似患者自述进行对比

            var report_similary = text_usr_dict[i]['report'];

            // 将相同关键词用红色标出
            if (text_usr_dict[i]['report_same'] !== 'NULL'){
                var report_same_split = text_usr_dict[i]['report_same'].split('*@*');

                for(m=0;m<report_same_split.length;m++){

                     if (report_orig &&  report_orig.indexOf(report_same_split[m]) !== -1 ) {
                                  var rego = new RegExp(report_same_split[m], "g");
                                  report_orig = report_orig.replace(rego, "<font color='red'>" + report_same_split[m] + '</font>');
                          }
                     if (report_similary &&  report_similary.indexOf(report_same_split[m]) !== -1 ) {
                                  var regs = new RegExp(report_same_split[m], "g");
                                  report_similary = report_similary.replace(regs, "<font color='red'>" + report_same_split[m] + '</font>');
                          }
                }

            }



            //将原始舌照特征数据与相似患者数据进行对比，
            var tongue_orignal = '';
            var tongue_similary = '';

            var tongue_abnormal_same_orig = '';
            var tongue_abnormal_same_simi = '';
            // 将相同异常的答案用红色标出
            if (text_usr_dict[i]['same_feature'] !== 'NULL'){
                var tongue_abnormal_same_split = text_usr_dict[i]['same_feature'].split('*@*');

                for(m=0;m<tongue_abnormal_same_split.length;m+=2){
                    tongue_abnormal_same_orig += "<font color='red'>" + tongue_abnormal_same_split[m] +'</font>' + ',';
                    tongue_abnormal_same_simi += "<font color='red'>" + tongue_abnormal_same_split[m+1] +'</font>'+ ',';
                }

            }
            else{
                   tongue_abnormal_same_orig += "<font color='red'>" + 'NULL' +'</font>' + ',';
                   tongue_abnormal_same_simi += "<font color='red'>" + 'NULL' +'</font>'+ ',';

                }

            //将原始患者数据与相似患者数据进行对比，将不同异常用蓝色标出
            var tongue_normal_diff__orig = '';
            var tongue_normal_diff__simi = '';
            if (text_usr_dict[i]['different_feature'] !== 'NULL'){
                var tongue_normal_diff_split = text_usr_dict[i]['different_feature'].split('*@*');


                for(m=0;m<tongue_normal_diff_split.length;m+=2){
                    tongue_normal_diff__orig += "<font color='blue'>" + tongue_normal_diff_split[m] +'</font>' + ',';
                    tongue_normal_diff__simi += "<font color='blue'>" + tongue_normal_diff_split[m+1] +'</font>'+ ',';
                }
            }
            else{
                    tongue_normal_diff__orig += "<font color='blue'>" + 'NULL' +'</font>' + ',';
                    tongue_normal_diff__simi += "<font color='blue'>" + 'NULL' +'</font>'+ ',';
                }

            //将原始患者数据与相似患者数据进行对比，将不同异常用蓝色标出
            var tongue_same_normal__orig = '';
            var tongue_same_normal__simi = '';
            if (text_usr_dict[i]['same_normal'] !== 'NULL'){
                var tongue_same_normal_split = text_usr_dict[i]['same_normal'].split('*@*');


                for(m=0;m<tongue_same_normal_split.length;m+=2){
                    tongue_same_normal__orig += "<font color='green'>" + tongue_same_normal_split[m] +'</font>' + ',';
                    tongue_same_normal__simi += "<font color='green'>" + tongue_same_normal_split[m+1] +'</font>'+ ',';
                }
            }
            else{
                    tongue_same_normal__simi += "<font color='green'>" + 'NULL' +'</font>' + ',';
                    tongue_same_normal__simi += "<font color='green'>" + 'NULL' +'</font>'+ ',';
                }



            tongue_orignal += tongue_abnormal_same_orig + tongue_normal_diff__orig + tongue_same_normal__orig;
            tongue_similary += tongue_abnormal_same_simi + tongue_normal_diff__simi + tongue_same_normal__simi;

            tongue_orignal = tongue_orignal.replace(/,/g, '<br>');
            tongue_similary = tongue_similary.replace(/,/g, '<br>');


            //将原始患者数据与相似患者数据进行对比，
            var inquiry_orignal = '';
            var inquiry_similary = '';

            var abnormal_same_orig = '';
            var abnormal_same_simi = '';
            // 将相同的答案用红色标出
            if (text_usr_dict[i]['abnormal_same_inquiry'] !== 'NULL'){
                var abnormal_same_split = text_usr_dict[i]['abnormal_same_inquiry'].split('*@*');

                for(m=0;m<abnormal_same_split.length;m+=2){
                    abnormal_same_orig += "<font color='red'>" + abnormal_same_split[m] +'</font>' + ',';
                    abnormal_same_simi += "<font color='red'>" + abnormal_same_split[m+1] +'</font>'+ ',';
                }

            }
            else{
                   abnormal_same_orig += "<font color='red'>" + 'NULL' +'</font>' + ',';
                   abnormal_same_simi += "<font color='red'>" + 'NULL' +'</font>'+ ',';

                }

            //将原始患者数据与相似患者数据进行对比，将不同的答案用蓝色标出
            var normal_diff__orig = '';
            var normal_diff__simi = '';
            if (text_usr_dict[i]['normal_diff_inquiry'] !== 'NULL'){
                var normal_diff_split = text_usr_dict[i]['normal_diff_inquiry'].split('*@*');


                for(m=0;m<normal_diff_split.length;m+=2){
                    normal_diff__orig += "<font color='blue'>" + normal_diff_split[m] +'</font>' + ',';
                    normal_diff__simi += "<font color='blue'>" + normal_diff_split[m+1] +'</font>'+ ',';
                }
            }
            else{
                    normal_diff__orig += "<font color='blue'>" + 'NULL' +'</font>' + ',';
                    normal_diff__simi += "<font color='blue'>" + 'NULL' +'</font>'+ ',';
                }
            //将原始遗留问题标出
            var source_remain__orig = '';
            if (text_usr_dict[i]['source_remain_inquiry'] !== 'NULL'){
                var source_remain_split = text_usr_dict[i]['normal_diff_inquiry'].split('*@*');


                for(m=0;m<source_remain_split.length;m++){
                    source_remain__orig +=  source_remain_split[m] + ',';
                }
            }
            else{
                   source_remain__orig = 'NULL'+ ',' ;
                }

             //将相似遗留问题标出
            var target_remain__simi = '';
            if (text_usr_dict[i]['target_remain_inquiry'] !== 'NULL'){
                var target_remain__split = text_usr_dict[i]['target_remain_inquiry'].split('*@*');

                for(m=0;m<target_remain__split.length;m++){
                    target_remain__simi += target_remain__split[m]  + ',';
                }
            }
            else{
                   target_remain__simi = 'NULL'+ ',' ;
                }

            inquiry_orignal += abnormal_same_orig + normal_diff__orig + source_remain__orig;
            inquiry_similary += abnormal_same_simi + normal_diff__simi + target_remain__simi;

            inquiry_orignal = inquiry_orignal.replace(/,/g, '<br>');
            inquiry_similary = inquiry_similary.replace(/,/g, '<br>');

            // 舌照url,判断
            // if (text_usr_dict[i].tongue_pic !== 'NULL'){
            //     var url = 'http://192.168.0.139:8899/static/img/"+text_usr_dict[i].tongue_pic+".jpg';
            // }
            var url = 'http://192.168.0.139:8899/static/img/"+text_usr_dict[i].tongue_pic+".jpg';


            var diagnosis_string = text_usr_dict[i]['diagnosis'];
             if ( diagnosis_string !== 'NULL') {
                 diagnosis_string = diagnosis_string.replace('辨证或辨病：','');
             }
            if ( diagnosis_orig !== 'NULL') {
                 diagnosis_orig = diagnosis_orig.replace('辨证或辨病：','');
             }

             var herbs_string = 'NULL';
             if (text_usr_dict[i]['herbs'] !== 'NULL') {
                 herbs_string = text_usr_dict[i]['herbs'].replace(/,/g, '<br>');
             }

            // var basic_info_simi = text_usr_dict[i]['basic_info'].replace('0.0','男');
            //表格的每一行
            table+="<tr><td>"+text_usr_dict[i].id+"</td>";

            table += "<td>"+text_usr_dict[i]['basic_info']+"</td>";
            table += "<td>"+user_info+"</td>";
            table+= "<td>"+text_usr_dict[i]['basic_info_sim']+"</td>";

            table+= "<td>"+report_similary+"</td>"; //相似自述
            table+= "<td>"+report_orig+"</td>";   //原始自述
            table+= "<td>"+text_usr_dict[i]['report_sim']+"</td>";

            table+= "<td>"+inquiry_similary+"</td>";  //相似病人答案
            table+= "<td>"+inquiry_orignal+"</td>";  //原始病人答案
            table+= "<td>"+text_usr_dict[i]['inquiry_sim']+"</td>";

            table+= "<td>"+tongue_similary+"</td>";    //相似舌照特征
            table+= "<td>"+tongue_orignal+"</td>";     //原始舌照特征
            table+= "<td>"+text_usr_dict[i]['tongue_sim']+"</td>";

            table += "<td><li ><a href='http://192.168.0.139:8899/static/img/"+text_usr_dict[i].tongue_pic+".jpg' >查看</a></li></td>";
            table += "<td><li ><a href='http://192.168.0.139:8899/static/img/"+text_usr_dict[i].tongue_pic+".jpg'>查看</a></li></td>";

            table+= "<td>"+diagnosis_string+"</td>";
            table+= "<td>"+diagnosis_orig+"</td>";

            table+= "<td>"+herbs_string+"</td>";
            table+= "<td>"+herbs+"</td>";

            table+= "<td>"+text_usr_dict[i]['total_sim']+"</td>" + "</tr>";
        }
        table += "</table>";
        $('#container').html(table);

    });


</script>
</body>

{% endblock %}


</html>